// pages/ListPage/ListPage.ts
Page({
  data: {
    list: [],
  },

  onLoad() {
    this.loadRankList();
  },

  loadRankList() {
    wx.request({
      url: 'https://m.douban.com/rexxar/api/v2/movie/rank_list',
      method: 'GET',
      success: (res: any) => {
        const list = res.data.subject_collection_boards?.map((board: any) => ({
          ...board.subject_collection,
          cover_url: board.subject_collection.cover.url,
          update_info: board.update_info
        })) ?? [];
        this.setData({ list });
      },
      fail: (err) => {
        console.error(err);
      }
    });
  },

  goDetail(e: any) {
    const id = e.currentTarget.dataset.id;
    // 这里可以跳转到榜单详情页，目前暂不实现
    console.log('go to rank detail, id:', id);
  }
})